﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AbpEntityFrameworkcore.Migrations
{
    /// <inheritdoc />
    public partial class YourMigrationName : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "lognote",
                columns: table => new
                {
                    Id_logNote = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    DateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Note = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    User = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Definition = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "说明"),
                    MaterialCode = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "物料编码"),
                    MaterialName = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "物料名称"),
                    Batch = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "批次"),
                    Size = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "大小"),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "工单号"),
                    BoxCode = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "料盒"),
                    WarehouseLineCode = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "位置")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_lognote", x => x.Id_logNote);
                });

            migrationBuilder.CreateTable(
                name: "Position",
                columns: table => new
                {
                    Position_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    PositionCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsOccupy = table.Column<bool>(type: "bit", nullable: false),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Position", x => x.Position_Id);
                });

            migrationBuilder.CreateTable(
                name: "TaskOrder",
                columns: table => new
                {
                    Taskorder_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    TaskOrderCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Origination_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Target_Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TaskOrder", x => x.Taskorder_Id);
                    table.ForeignKey(
                        name: "FK_TaskOrder_Position_Origination_Id",
                        column: x => x.Origination_Id,
                        principalTable: "Position",
                        principalColumn: "Position_Id");
                    table.ForeignKey(
                        name: "FK_TaskOrder_Position_Target_Id",
                        column: x => x.Target_Id,
                        principalTable: "Position",
                        principalColumn: "Position_Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_TaskOrder_Origination_Id",
                table: "TaskOrder",
                column: "Origination_Id");

            migrationBuilder.CreateIndex(
                name: "IX_TaskOrder_Target_Id",
                table: "TaskOrder",
                column: "Target_Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "lognote");

            migrationBuilder.DropTable(
                name: "TaskOrder");

            migrationBuilder.DropTable(
                name: "Position");
        }
    }
}
